
using Admin2025.Domain.Repositories;
using Admin2025.Infrastructure.Data;
using Admin2025.Infrastructure.Repositories;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Admin2025.Infrastructure;

public static class ServiceCollenctionExtensions
{
    public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
    {
        //注册数据库上下文到容器
        services.AddDbContext<Admin2025DbContext>(options =>
        options.UseNpgsql(configuration.GetConnectionString("pgsql")));
        //可在此注册更多基础设施相关服务

        
        //注册仓储接口
        services.AddScoped(typeof(IRepository<>), typeof(EfRepository<>));
        return services;
    } 
}